package com.alibaba.utils.qrcode;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author com.alibaba.lizhen
 * @Date 2021/1/13 5:25 下午
 * @Version 1.0
 * @Description
 */
public class ThreadUtils {

    private static Logger logger = LoggerFactory.getLogger(ThreadUtils.class);

    private static final ThreadPoolExecutor executor;

    private static final int factor = 1;

    static {
        executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * factor);
        logger.debug("create " + Runtime.getRuntime().availableProcessors() * factor+ " threads");
    }


    public static ThreadPoolExecutor getExecutor() {
        return executor;
    }
}
